import { applyMiddleware, createStore , combineReducers} from 'redux';
import { createLogger } from 'redux-logger'
import createSagaMiddleware from 'redux-saga';
import rootSaga from './RootSagas';

// reducers
import UserReducer from './user/reducers/UserReducer';

const logger = createLogger();
const sagaMiddleware = createSagaMiddleware();

// const middlewares = [thunk, sagaMiddleware, logger];
const middlewares = [sagaMiddleware];

// 设置所有的reducer
const rootReducer = combineReducers({
  user: UserReducer,
})

export default function configureStore() {
  const store = createStore(rootReducer, applyMiddleware( ...middlewares));
  sagaMiddleware.run(rootSaga);
  return store;
}